@extends("layout.admin")

@section("title")
    添加考试批次成员
@endsection

@section("content")
    <style>
        .help-block {
            display: block;
            margin-top: 5px;
            margin-bottom: 10px;
            color: #737373;
        }
    </style>
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li><a href="{{route('admin.basic.membercreate',['batch_id'=>request('batch_id')])}}">用户名开通</a> </li>
                <li class="layui-this">岗位开通</li>
                <li><a href="{{route('admin.basic.membercreate.attach',['batch_id'=>request('batch_id')])}}">部门开通</a></li>
            </ul>
            <div class="layui-tab-content" style="height: 100px;">
                <form class="layui-form layui-col-space5 layui-input-inline" action="{{route('admin.basic.membercreate.attach.1')}}">
                    @csrf
                    <div class="demoTable">
                        <div class="layui-inline">
                            <select name="post_id">
                                <option value="">请选择岗位</option>
                                @foreach($post as $vo)
                                <option value="{{$vo['id']}}">{{$vo['name']}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="layui-inline">
                            <select name="type">
                                <option value="">请选择添加类型</option>
                                <option value="1">全部添加</option>
                                <option value="2">部分添加</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit lay-filter="*"><i class="layui-icon"></i>添加
                            </button>
                        </div>
                    </div>
                </form>
                <table lay-filter="table-hide" style="display: none"  lay-data="{height:'full-100', cellMinWidth: 80,toolbar: '#toolbar1',defaultToolbar:['filter'],limit:{{$user['per_page']}}}">
                    <thead>
                    <tr>
                        <th lay-data="{width:80,type:'checkbox',field:'id'}"></th>
                        <th lay-data="{field:'name'}">用户名</th>
                        <th lay-data="{field:'name'}">组织机构</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach ($user['data'] as $vo)
                        <tr>
                            <td></td>
                            <td>{{$vo['name']}}</td>
                            <td>{{$vo['name'] }}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                @include("layout.page")
            </div>

        </div>
    </div>
    </div>
@endsection
@section('script')
    <script src="{{asset('layui/modules/xm-select.js')}}"></script>
    <script src="{{asset('js/tree/select.js')}}"></script>
    <script>
        var idx = -1;
        layui.use(['form','table','xmSelect'], function () {
            var table = layui.table;
            var form = layui.form,xmSelect = layui.xmSelect;
            table.init("table-hide");
            form.on("submit(*)", function (data) {
                var obj = $(this);
                //obj.attr("disabled", "disabled").addClass("layui-disabled");
                $.post(data.form.action, data.field, function (data) {
                    var icon = 5;
                    if (data.code == "0") {
                        icon = 6;
                    }
                    layer.msg(data.msg, {icon: icon, time: 1500}, function () {   //提示的插件，可以使用alert代替
                        if (data.code==0) {
                            setTimeout(function () {
                                //刷新父页面
                                window.location.reload();
                            }, 500);
                        } else {
                            //obj.removeAttr("disabled").removeClass("layui-disabled");
                        }
                    });
                }, 'json');
                return false;
            });
            admin.paginate("{{ $user['total'] }}", "{{ $user['current_page'] }}", "{{ $user['per_page'] }}");
        });
    </script>
@endsection
